package edu.kit.aifb.ruleintegrator.rule;

import java.util.ArrayList;
import java.util.List;

import org.semanticweb.yars.nx.Variable;

import edu.kit.aifb.ruleintegrator.util.RuleException;

public class Rule {

	private List<RulePredicate> m_predicates;
	private RulePredicate m_head;
	private Signature m_signature;
	
	private List<RulePredicate> m_addablePredicates;
	private List<RulePredicate> m_deletablePredicates;
		

	public Rule(RulePredicate head){
		this.m_signature=new Signature(new Variable[]{});
		this.m_predicates=new ArrayList<RulePredicate>();
		this.m_head=head;
		this.m_addablePredicates=new ArrayList<RulePredicate>();
		this.m_deletablePredicates=new ArrayList<RulePredicate>();
	}
	
	public void addPredicate(RulePredicate pred) throws RuleException{
		if(!m_addablePredicates.contains(pred))
			throw new RuleException("Exception in Rule: Predicate is not addable ("+pred.toString()+")");
		this.m_predicates.add(pred);
		this.m_deletablePredicates.add(pred);
		this.m_addablePredicates.remove(pred);
	}
	
	
	public void addAddablePredicate(RulePredicate pred){
		this.m_addablePredicates.add(pred);
	}
	
	public List<RulePredicate> getBody() {
		return m_predicates;
	}
	
	public RulePredicate getHead(){
		return m_head;
	}
	
	public Signature getSignature(){
		return this.m_signature;
	}

}
